<?php
if(isset($_GET['dept']))
    $deptno=$_GET['dept'];
else
    $deptno= '10001';
// **********found**********
$con=mysql_connect("localhost:3307","root","123456")
or die("数据库服务器连接失败！<br>");
// **********found**********
mysql_select_db("nrce-05",$con) or die( "数据库选择失败！<br>");
// **********found**********
$sql_student="SELECT sid,score FROM student WHERE deptno = '".$deptno."'";
$result_student=mysql_query($sql_student,$con);

$sql_dept="SELECT deptno,deptname FROM dept";
$result_dept=mysql_query($sql_dept,$con);

?>
<!--<form action='sj3.php' method='GET'>-->
<form action='NRCE-05.php' method='GET'>
    请选择一个系：
    <select name="dept">
        <?php
        // **********found**********
        while($rows_dept=mysql_fetch_array($result_dept)){
            ?>
            <option value='<?php echo $rows_dept[0];?>'
                <?php if($rows_dept[0]==$deptno) echo 'selected="selected"' ?>
            >
                <?php echo $rows_dept[1];?>
            </option>
            <?php
        }
        ?>

    </select>
    <!--// **********found********** -->
    <input type="submit"/>
</form>
<table border='1px'>
    <tr>
        <td>学号</td>
        <td>成绩</td>
    </tr>
    <?php
    while($rows_student=mysql_fetch_array($result_student)){
        ?>
        <tr>
            <td><?php echo $rows_student[0];?></td>
            <td><?php echo $rows_student[1];?></td>
        </tr>
        <?php
    }
    mysql_close($con);
    ?>
</table>
